]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Listen to MetaBackend::last-device-changed for OSK changes
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 10 Mar 2015 16:49:56 +0000 (17:49 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 13 Mar 2015 20:08:51 +0000 (21:08 +0100)
Instead of listening to a dbus property exported by g-s-d, listen to the
MetaBackend signal telling the last interacted device, and make sure we
only show the keyboard for touchscreens.

https://bugzilla.gnome.org/show_bug.cgi?id=745977

js/ui/keyboard.js

index 8dc154bc9b545eaa72aa6b64caf997d194e8523a..393a179e86cde95a414b6bbae7070dc6cc588bd6 100644 (file)
@@ -6,6 +6,7 @@ const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Lang = imports.lang;
+const Meta = imports.gi.Meta;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
@@ -60,14 +61,7 @@ const CaribouDaemonIface = '<node> \
 </interface> \
 </node>';
 
-const CursorManagerIface = '<node> \
-<interface name="org.gnome.SettingsDaemon.Cursor"> \
-<property name="ShowOSK" type="b" access="read" /> \
-</interface> \
-</node>';
-
 const CaribouDaemonProxy = Gio.DBusProxy.makeProxyWrapper(CaribouDaemonIface);
-const CursorManagerProxy = Gio.DBusProxy.makeProxyWrapper(CursorManagerIface);
 
 const Key = new Lang.Class({
     Name: 'Key',
@@ -188,17 +182,18 @@ const Keyboard = new Lang.Class({
                                                Lang.bind(this, this._sync),
                                                Lang.bind(this, this._sync));
         this._daemonProxy = null;
-        this._cursorProxy = new CursorManagerProxy(Gio.DBus.session, CURSOR_BUS_NAME,
-                                                   CURSOR_OBJECT_PATH,
-                                                   Lang.bind(this, function(proxy, error) {
-                                                       if (error) {
-                                                           log(error.message);
-                                                           return;
-                                                       }
-                                                       this._cursorProxy.connect('g-properties-changed',
-                                                                                 Lang.bind(this, this._sync));
-                                                       this._sync();
-                                                   }));
+        this._lastDeviceId = null;
+
+        Meta.get_backend().connect('last-device-changed', Lang.bind(this,
+            function (backend, deviceId) {
+                let manager = Clutter.DeviceManager.get_default();
+                let device = manager.get_device(deviceId);
+
+                if (device.get_device_name().indexOf('XTEST') < 0) {
+                    this._lastDeviceId = deviceId;
+                    this._sync();
+                }
+            }));
         this._sync();
 
         this._showIdleId = 0;
@@ -217,9 +212,22 @@ const Keyboard = new Lang.Class({
         this._redraw();
     },
 
+    _lastDeviceIsTouchscreen: function () {
+        if (!this._lastDeviceId)
+            return false;
+
+        let manager = Clutter.DeviceManager.get_default();
+        let device = manager.get_device(this._lastDeviceId);
+
+        if (!device)
+            return false;
+
+        return device.get_device_type() == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE;
+    },
+
     _sync: function () {
         this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD) ||
-                               this._cursorProxy.ShowOSK;
+                               this._lastDeviceIsTouchscreen();
         if (!this._enableKeyboard && !this._keyboard)
             return;
         if (this._enableKeyboard && this._keyboard &&